<template>
	<view>
		<view class="header_user colfff">
			<view class="rowsal" style="height: 400rpx;">
				<view class="tct">
					<image :src="image+coachUserInfo.img" mode="" style="width: 100rpx;height: 100rpx;border-radius: 50%;background-color: #F1F1F1;"></image>
					<view class="fs26">{{coachUserInfo.name || '教练中心'}}</view>
					<view class="fs26">{{coachUserInfo.tel }}</view>
				</view>
				<view class="rowsa tct">
					<view>
						<view class="fs26">{{coachUserInfo.num}}</view>
						<view class="fs26">学员人数</view>
					</view>
					<view>
						<view class="fs26" v-if="coachUserInfo.star !=null">{{coachUserInfo.star}}</view>
						<view class="fs26" v-else>0</view>
						<view class="fs26">评分</view>
					</view>
				</view>
			</view>
		</view>
		<view>
			<view class="level_user fs30 col333 bold pdBtm20 pdTop20 pdlft20">学员信息</view>
			<view>
				<view class="content rows" v-for="(item,index) in studentList" :key="item.id" @click="coachInformation(item)">
					<image :src="image+item.img" mode="" style="max-width: 200rpx;height: 200rpx;border-radius: 10rpx;background-color: #F1F1F1;"></image>
					<view class="rowsal pdlft20 w100" style="height: 200rpx;">
						<view class="fs28 col333 bold">{{item.name}}</view>
						<view class="rowsb w100">
							<view class="fs26 col666">{{item.coach_title}}</view>
							<view class="arrow mrTop10"></view>
						</view>
						<view class="fs26 col666">{{item.tel}}</view>
					</view>
				</view>
			</view>
			<view v-if="studentList==''" class="text-center padding text-gray text-sm">
				暂无更多
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp().globalData
	import {
		coachUser,
		user_list,
		bookedList
	} from '../../../common/path.js'
	export default {
		data() {
			return {
				coachUserInfo: {},
				studentList: [], //获取到的学员信息
				image: '' ///拼接
			}
		},
		onShow() {
			this.image = app.image
			this.coachUser() //教练中心
			this.user_list() //学员列表
			
			console.log(app.userInfo.id);
		},
		methods: {
			coachInformation(item) {
				uni.navigateTo({
					url: 'coachInformation?detail=' + JSON.stringify(item)
				})
			},
			//获取教练中心
			coachUser() {
				let data = {
					id: app.userInfo.id
				}
				this.$axios.axios('POST', coachUser, data)
					.then(res => {
						console.log('获取到的教练信息', res);
						if (res.status == 1) {
							this.coachUserInfo = res.data
							// this.starLength = Number(res.data.star.split(".")[0])
						}
					})
					.catch(err => {
						console.log(err);
					})
			},
			//获取我的学员报名记录
		

			//获取学员
			user_list() {
				let data = {
					id: app.userInfo.id
				}
				this.$axios.axios('POST', user_list, data)
					.then((res) => {
						console.log('获取到的用户信息===>', res.data);
						if (res.status == 1) {
							this.studentList = res.data
						}
					})
			}
		}
	}
</script>

<style scoped>
	page {
		background-color: #FFFFFF;
	}

	.header_user {
		width: 750rpx;
		height: 400rpx;
		background-image: url(https://dss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2529989314,64710101&fm=26&gp=0.jpg);
		background-repeat: no-repeat;
		background-size: 100% 100%;
	}

	.level_user {
		border-top: 12rpx solid #F1F1F1;
		border-bottom: 3rpx solid #F1F1F1;
	}

	.content {
		width: 710rpx;
		border-bottom: 3rpx solid #F1F1F1;
		padding: 20rpx;
	}
</style>
